# Contributor: Adrian L Lange <alpine@p3lim.net>
# Contributor: Charles Wimmer <charles@wimmer.net>
# Contributor: Dermot Bradley <dermot_bradley@yahoo.com>
maintainer="Wolfgang Fischer <wdev@posteo.org>"
pkgname=step-cli
pkgver=0.28.0
pkgrel=0
pkgdesc="Zero trust swiss army knife that integrates with step-ca for automated certificate management"
url="https://github.com/smallstep/cli"
arch="all"
license="Apache-2.0"
makedepends="
	bash
	go
	go-bindata
	"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/smallstep/cli/archive/refs/tags/v$pkgver.tar.gz
	"
options="net"
builddir="$srcdir/cli-$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make CGO_OVERRIDE= build
}

check() {
	go test -trimpath=false ./...
}

package() {
	make CGO_OVERRIDE= DESTDIR="$pkgdir"/usr/bin install

	install -Dm644 autocomplete/bash_autocomplete \
		"$pkgdir"/usr/share/bash-completion/completions/step

	install -Dm644 autocomplete/zsh_autocomplete \
		"$pkgdir"/usr/share/zsh/site-functions/_step
}

sha512sums="
42f27d8ac76075ba2e9c81657bcf77615baaf4176b7921520809bff66ba2fd4859a9661b18088fabe3c426dd0d6562abb07225b7b8675347eceb428358d9f8e6  step-cli-0.28.0.tar.gz
"
